package com.building18.mapper;

import com.building18.pojo.Owner;
import com.building18.pojo.vo.OwnerVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OwnerMapper {

    @Select("select * from owner_info")
    List<Owner> selectOwner();

    @Insert("insert into owner_info(name, telephone, gender, idcard, remark, house_id) " +
            "values(#{name}, #{telephone}, #{gender}, #{idcard}, #{remark}, #{houseId})")
    Integer addOwner(Owner owner);

    @Delete("delete from owner_info where id = #{id}")
    Integer deleteOwnerById(Integer id);

    @Update("update owner_info set name = #{name}, telephone = #{telephone}, gender = #{gender}, " +
            "idcard = #{idcard}, remark = #{remark}, house_id = #{houseId} where id = #{id}")
    Integer updateOwner(Owner owner);

    List<Owner> selectOwnerByName(String name);

    Integer deleteOwnerByIds(@Param("ids") Integer[] ids);

    @Select("select id,name from owner_info")
    List<OwnerVO> getOwnerNameAndId();
    @Select("select * from owner_info where id = #{id}")
    OwnerVO getOwnerById(Integer id);
}